package com.song.quartz;

import groovy.lang.Binding;
import groovy.lang.GroovyShell;

import java.math.BigDecimal;
import java.math.RoundingMode;

public class MainTest {
    public static void main(String[] args) {
        Binding binding = new Binding();
        binding.setVariable("yjgjhcczYxhcczl", "80.25");
        binding.setVariable("yjgjhcczWjscqckczcs", 2);
//        String gs = "def fs = 0.4; fs = 0.4 - (pm -1) * 0.05; if(fs < 0){fs =0}; if (fs > 0.4){fs = 0.4}; return fs";
//        String gs = "def fs = 0.2; fs = dyjdBjckryDjclXzcf * 0.02 + dyjdBjckryDjclQzcs * 0.05; if(fs < 0){fs =0}; if (fs > 0.2){fs = 0.2}; return fs";
//        String gs = "def fs = 1; fs = 1 - dejdJjxflyjGxdj * 0.05 - dejdJjxflyjHb * 0.2; if(fs < 0){fs =0}; if (fs > 1){fs = 1}; return fs";
//        String gs = "def fs = 0.5; fs = 0.5 - dejdBjgajgckCks * 0.05; if(fs < 0){fs =0}; if (fs > 0.5){fs = 0.5}; return fs";
//        String gs = "def fs = 0; fs = dyjdDkfxSksflrySz * 0.02 + dyjdDkfxSksflryFsz * 0.02; return fs";
//        String gs = "def fs = 0; fs = dejdDkfxSksflrySz * 0.02 + dejdDkfxSksflryFsz * 0.02; return fs";
//        String gs = "def fs = 0; if (dejdDkfxFspdwbdryRs > 0) {fs = dejdJjxflyjDf * 0.5}; return fs";
//        String gs = "def fs = 0.15; if (dyjdJjxflyjHhbSthhb > 0) {fs = fs + dyjdJjxflyjHhbSthhb * 0.01 * 2} else {fs = fs + dyjdJjxflyjHhbSjhhb * 0.01}; if (dyjdJjxflyjHhbSthb > 0) {fs = fs - dyjdJjxflyjHhbSthb * 0.01 * 2} else {fs = fs - dyjdJjxflyjHhbSjhb * 0.01}; if(fs < 0){fs =0}; if (fs > 0.2){fs = 0.2}; return fs";
//        String df = "def fs = 0.8; if(zdryjcpcRklkl >= 90) {fs = 0.8 - zdryjcpcPcbhgrs * 0.01}else if(zdryjcpcRklkl < 60){fs = 0}else if (zdryjcpcRklkl < 90 && zdryjcpcRklkl >= 85){fs = 0.8 - 0.05 - zdryjcpcPcbhgrs * 0.01}else if (zdryjcpcRklkl < 85 && zdryjcpcRklkl >= 80){fs = 0.8 - 0.05 * 2 - zdryjcpcPcbhgrs * 0.01}else if (zdryjcpcRklkl < 80 && zdryjcpcRklkl >= 75){fs = 0.8 - 0.05 * 3 - zdryjcpcPcbhgrs * 0.01}else if (zdryjcpcRklkl < 75 && zdryjcpcRklkl >= 70){fs = 0.8 - 0.05 * 4 - zdryjcpcPcbhgrs * 0.01}else if (zdryjcpcRklkl < 70 && zdryjcpcRklkl >= 65){fs = 0.8 - 0.05 * 5 - zdryjcpcPcbhgrs * 0.01}else if (zdryjcpcRklkl < 65 && zdryjcpcRklkl >= 60){fs = 0.8 - 0.05 * 6 - zdryjcpcPcbhgrs * 0.01}; if(fs < 0){fs =0}; if (fs > 0.8){fs = 0.8}; return fs";
//        String df = "def fs = 0.7; if(yjgjhcczYxhcczl >= 90) {fs = 0.7 - yjgjhcczWjscqckczcs * 0.02}else if(yjgjhcczYxhcczl < 60){fs = 0}else if (yjgjhcczYxhcczl < 90 && yjgjhcczYxhcczl >= 85){fs = 0.7 - 0.05 - yjgjhcczWjscqckczcs * 0.02}else if (yjgjhcczYxhcczl < 85 && yjgjhcczYxhcczl >= 80){fs = 0.7 - 0.05 * 2 - yjgjhcczWjscqckczcs * 0.02}else if (yjgjhcczYxhcczl < 80 && yjgjhcczYxhcczl >= 75){fs = 0.7 - 0.05 * 3 - yjgjhcczWjscqckczcs * 0.02}else if (yjgjhcczYxhcczl < 75 && yjgjhcczYxhcczl >= 70){fs = 0.7 - 0.05 * 4 - yjgjhcczWjscqckczcs * 0.02}else if (yjgjhcczYxhcczl < 70 && yjgjhcczYxhcczl >= 65){fs = 0.7 - 0.05 * 5 - yjgjhcczWjscqckczcs * 0.02}else if (yjgjhcczYxhcczl < 65 && yjgjhcczYxhcczl >= 60){fs = 0.7 - 0.05 * 6 - yjgjhcczWjscqckczcs * 0.02}; if(fs < 0){fs =0}; if (fs > 0.7){fs = 0.7}; return fs";
//        String df = "def fs = 0.5; fs = 0.5 - fxhjczCtzlbj * 0.01 - fxhjczGabstbj * 0.02 - fxhjczCtzlsk * 0.01 - fxhjczGabsthcbjs * 0.03; if(fs < 0){fs =0}; if (fs > 0.5){fs = 0.5}; return fs";
//        String df = "def fs = 0.5; def fjfs = 0.2; fs = 0.5 * shstdaj5ryxWcl; if (fs > 0.5){fs = 0.5}; if(shstdaj5ryxBls > shstdaj5ryxQnmbs) {fjfs = shstdaj5ryxYss * 0.1}; if (fjfs > 0.2) {fjfs = 0.2}; return fs + fjfs";
//        String df = "def fs = 0.5; def fjfs = 0.2; fs = 0.5 * qthd5rysthajWcl; if (fs > 0.5){fs = 0.5}; if(qthd5rysthajBls > qthd5rysthajQnmbs) {fjfs = qthd5rysthajYss * 0.1}; if (fjfs > 0.2) {fjfs = 0.2}; return fs + fjfs";
//        String df = "def fs = 0.1; if(shstdaj5rysBls < shstdaj5rysQnmbs) {fs = 0}; return fs";
//        String df = "def fs = 0; if (slzaajBjl < 55){(55 - slzaajBjl) * 0.01}; return fs";
//        String df = "def fs = 0; if (mypclajXscfajs < mypclajQncfajmbs){(mypclajQncfajmbs - mypclajXscfajs) * 0.01}; return fs";
//        String df = "def fs = 0; if (cfzjzpylfwcsstdxgrysDbl < 100){(100 - cfzjzpylfwcsstdxgrysDbl) * 0.01}; return fs";
//        String df = "def fs = 0.5 - dwlcs * 0.01 - cyrylcs * 0.001; if(fs < 0){fs =0}; return fs";
        int internal = internal(80, 69, 5);
        System.out.println(internal);
        String df = "def fs = 0.1; fs = 0.1 - interval * 0.01; if(fs < 0){fs =0}; return fs";
        GroovyShell groovyShell = new GroovyShell(binding);
        Object evaluate = groovyShell.evaluate(df);
//        System.out.println("返回结果：" + evaluate);
        int i = new BigDecimal(61.29).intValue();
        System.out.println(i);
    }

    public static int internal(double d1, double d2, int i){
        BigDecimal b = new BigDecimal((d1 - d2) / i);
        if (b.doubleValue() > b.intValue()){
            return b.intValue() + 1;
        }
        return b.intValue();
    }
}
